<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>列表</title>
  <script src="https://cdn.staticfile.org/react/16.4.0/umd/react.development.js"></script>
  <script src="https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js"></script>
  <script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>
</head>
<body>
<div id="root"></div>
</body>
<script type="text/babel">
class List extends React.Component{
  constructor (props){
    super(props);
  }
}
const numbers = [1, 2, 3, 4, 5];
const listItems = numbers.map((number,index) =>
  <li key={index}>{number}</li>
);

class ListItem extends React.Component{
  constructor (props){
    super(props);
    this.state.props = props;
  }

  render(){
    return (<li key={this.state.props.key}>{this.state.props.value}</li>);
  }
}
const posts = [
  {id: 1, title: 'Hello World', content: 'Welcome to learning React!'},
  {id: 2, title: 'Installation', content: 'You can install React from npm.'}
];
const  content = posts.map((post)=>{
  <ListItem key={post.id} value={post.title}></ListItem>
})
ReactDOM.render(<ul>{content}</ul>,document.getElementById('root'));

</script>
</html>
